<%@ Page Language="C#" MasterPageFile="~/Site.master" Theme="Default" EnableTheming="true" 
    AutoEventWireup="true" CodeFile="ListBooks.aspx.cs" Inherits="ListBooks" 
    Title="Dr. Yurttas' Office Library &mdash; List Books" %>
<asp:Content ID="ContentAdmin" ContentPlaceHolderID="MasterContentAdmin" Runat="Server">
    <asp:LoginView ID="LoginViewAdmin" runat="server">
        <RoleGroups>
            <asp:RoleGroup Roles="admin">
                <ContentTemplate>
                    You are an administrator, please see the <a href="managebooks.aspx">Manage Books</a>
                    page for this kind of request.
                </ContentTemplate>
            </asp:RoleGroup>
        </RoleGroups>
    </asp:LoginView>                       
</asp:Content>
<asp:Content ID="ContentUser" ContentPlaceHolderID="MasterContentUser" Runat="Server">
    <asp:LoginView ID="LoginViewUser" runat="server">
        <RoleGroups>
            <asp:RoleGroup Roles="user">
                <ContentTemplate>
                    <asp:GridView Width="100%" ID="bookListView" AllowPaging="True" runat="server" 
                        OnRowCommand="bookListView_RowCommand"
                        DataSourceID="SqlDataSource1" AutoGenerateColumns="False" AutoGenerateEditButton="False" 
                        AutoGenerateDeleteButton="False" AllowSorting="True" DataKeyNames="bookid">
                        <Columns>
                            <asp:CommandField ControlStyle-Font-Size="0.8em" SelectText="Select" 
                                ControlStyle-Font-Names="Verdana" ControlStyle-BorderStyle="Solid" 
                                ControlStyle-BorderWidth="1px" ControlStyle-BorderColor="#CCCCCC" 
                                ControlStyle-ForeColor="#284775" ControlStyle-BackColor="#FFFBFF" 
                                ButtonType="Button" ShowSelectButton="true" />
                            <asp:BoundField DataField="bookid" HeaderText="ISBN" SortExpression="bookid" 
                                ReadOnly="True" InsertVisible="False" Visible="True" />
                            <asp:HyperLinkField DataTextField="title" 
                                DataNavigateUrlFormatString="http://www.amazon.com/gp/product/{0}" 
                                DataNavigateUrlFields="bookid" HeaderText="Title" SortExpression="title" />
                        </Columns>
                    </asp:GridView>
                    
                    <asp:Label ForeColor="Red" runat="server" ID="errorLabel" Text="That book is not available."
                        Width="100%"></asp:Label>
                    <br />
                    <asp:Label BackColor="#5D7B9D" CssClass="block" Font-Bold="True" ForeColor="White" 
                        Text="&nbsp;&nbsp;Details:" runat="server" ID="detailsLabel" Width="100%"></asp:Label>
                    <asp:DetailsView OnItemCommand="bookDetailsView_ItemCommand" Width="100%" 
                        runat="server" ID="bookDetailsView" DataSourceID="SqlDataSource1" DataKeyNames="bookid" 
                        AutoGenerateRows="false">
                        <Fields>
                            <asp:BoundField HeaderStyle-Width="100px" DataField="bookid" HeaderText="ISBN" 
                                ReadOnly="True" InsertVisible="False" Visible="True" />
                            <asp:BoundField HeaderStyle-Width="100px" DataField="title" HeaderText="Title" />
                            <asp:BoundField HeaderStyle-Width="100px" DataField="author" HeaderText="Author" />
                            <asp:BoundField HeaderStyle-Width="100px" DataField="publisher" HeaderText="Publisher" />
                            <asp:BoundField HeaderStyle-Width="100px" DataField="language" HeaderText="Language" />
                            <asp:BoundField HeaderStyle-Width="100px" DataField="number" HeaderText="Number" />
                            <asp:BoundField HeaderStyle-Width="100px" DataField="requested" HeaderText="Requested" />

                            <asp:ButtonField ControlStyle-Font-Size="0.8em" ControlStyle-Font-Names="Verdana" 
                                ControlStyle-BorderStyle="Solid" ControlStyle-BorderWidth="1px" 
                                ControlStyle-BorderColor="#CCCCCC" ControlStyle-ForeColor="#284775" 
                                ControlStyle-BackColor="#FFFBFF" ButtonType="Button" HeaderText="" 
                                CommandName="Request" Text="Requst" />
                        </Fields>
                    </asp:DetailsView>    
                    <asp:Label ForeColor="Red" Text="" runat="server" ID="detailsComplete" Width="100%"></asp:Label>

                    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:sylib %>"
                        SelectCommand="SELECT bookid, title, publisher, substring(title,0,25) AS shortTitle, 
                            substring(author,0,10) as shortAuthor, author, substring(publisher,0,15) AS shortPublisher,
                            language, number, requested FROM [books] ORDER BY [author], [title], [publisher]">
                    </asp:SqlDataSource>
                </ContentTemplate>
            </asp:RoleGroup>
        </RoleGroups>
    </asp:LoginView>                       
</asp:Content>
<asp:Content ID="ContentAnonymous" ContentPlaceHolderID="MasterContentAnonymous" Runat="Server">
    <asp:LoginView ID="LoginViewAnonymous" runat="server">
        <AnonymousTemplate>
            Please register before using this service.
        </AnonymousTemplate>
    </asp:LoginView>                       
</asp:Content>